//package com.mnyc.utils;
//
//import feign.Contract;
//import feign.codec.Decoder;
//import feign.codec.Encoder;
//import feign.form.spring.SpringFormEncoder;
//import feign.optionals.OptionalDecoder;
//import org.springframework.beans.factory.ObjectFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
//import org.springframework.cloud.openfeign.support.ResponseEntityDecoder;
//import org.springframework.cloud.openfeign.support.SpringDecoder;
//import org.springframework.cloud.openfeign.support.SpringEncoder;
//import org.springframework.cloud.openfeign.support.SpringMvcContract;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
//@Configuration
//public class FeignInterfaceFactory {
//    @Autowired
//    ObjectFactory<HttpMessageConverters> messageConverters;
//
//    /***
//     * 消息编码器
//     * @return
//     */
//    @Bean
//    Decoder feignClientDecoder() {
//        OptionalDecoder decoder = new OptionalDecoder(new ResponseEntityDecoder(new SpringDecoder(messageConverters)));
//        return decoder;
//    }
//
//    /**
//     * 消息解码器
//     *
//     * @return
//     */
//    @Bean
//    Encoder feignClientEncoder() {
//        SpringEncoder springEncoder = new SpringEncoder(messageConverters);
//        SpringFormEncoder encoder = new SpringFormEncoder(springEncoder);
//        return encoder;
//    }
//
//    @Bean
//    Contract feignClientContract() {
//        return new SpringMvcContract();
//    }
//
////    private <T> T createFeignClient(Class<T> tClass) {
////        T feignClient = Feign.builder()
////                .decoder(feignClientDecoder())
////                .encoder(feignClientEncoder())
////                .contract(feignClientContract())
////                .target(tClass, "http://localhost:8080/server");//传入url
////        return feignClient;
////    }
//}
